// Domien Nowicki
#include "QtRotateToEffect.h"
#include "QtSprite.h"

QtRotateToEffect::QtRotateToEffect(): target(0)
{
}

QtRotateToEffect::~QtRotateToEffect()
{
}

QtRotateToEffect::QtRotateToEffect(const QtRotateToEffect& rhs): QtSingleAnimationEffect(rhs), target(rhs.target), endAngle(rhs.endAngle), startAngle(rhs.startAngle)
{

}

void QtRotateToEffect::SetTarget(QtSprite *sprite)
{
	target = sprite;
}

QtSprite* QtRotateToEffect::Target() const
{
	return target;
}

void QtRotateToEffect::Update(qreal value)
{
	if (target)
	{	
		target->SetAngle( startAngle + (endAngle-startAngle)*value );
	}
}

void QtRotateToEffect::SetEndAngle(qreal angle)
{
	endAngle = angle;
}

void QtRotateToEffect::SetupAnimation()
{
	if (target)
	{
		startAngle = target->Angle();
	}
}

QtAnimationEffect* QtRotateToEffect::Clone() const
{
	return new QtRotateToEffect(*this);
}

